package com.deco.back.controller.content;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.deco.domain.vo.brand.BrandStoryVo;
import com.deco.domain.vo.sys.CmsAdvTypeVo;
import com.deco.domain.vo.sys.CmsAdvVo;
import com.deco.domain.vo.sys.CmsMediaTypeVo;
import com.deco.domain.vo.sys.CmsMediaVo;
import com.deco.service.brand.BrandStoryService;
import com.deco.service.sys.CmsAdvService;
import com.deco.service.sys.CmsMediaService;
import com.deco.service.sys.CmsMediaTypeService;
import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;
import com.free.common.vo.ResultModel;
import com.free.ext.web.spring.annoation.PageSearch;

/**
 * 文件管理 Controller
 * @author lengy
 *
 */
@Controller
public class CmsMediaController {
    @Autowired
    private CmsMediaService cmsMediaService;
    
    @Autowired
    private CmsMediaTypeService cmsMediaTypeService;
    
    @RequestMapping(value = "/cms_media_list.do")
    public ModelAndView listPage(){
        ModelAndView mv = new ModelAndView("content/cmsmedialist");
        List<CmsMediaTypeVo> typeList = cmsMediaTypeService.getAll();
        mv.addObject("typeList", typeList);
        return mv;
    }

    @RequestMapping(value= "/cms_media_list_page.do")
    @ResponseBody
    public PageResponseVo<CmsMediaVo> getList(@PageSearch PageSearchVo<CmsMediaVo> condition){
    	
        return cmsMediaService.pageInfo(condition);
    }

    @RequestMapping(value = "/cms_media_edit.do")
    public ModelAndView edit(Integer id){
        ModelAndView mv = new ModelAndView("content/cmsmediaedit");
        List<CmsMediaTypeVo> typeList = cmsMediaTypeService.getAll();
        mv.addObject("typeList", typeList);
        mv.addObject("actNm","新增");
        return mv;
    }

    @RequestMapping(value ="/cms_media_del.do")
    @ResponseBody
    public ResultModel batchDelete(@RequestParam(value = "ids[]")Integer[] ids){
        return cmsMediaService.batchDelete(ids);
    }

    @RequestMapping(value ="/cms_media_edit_submit.do")
    @ResponseBody
    public ResultModel udpate(CmsMediaVo vo){
        return cmsMediaService.save(vo);
    }

}
